<?
include_once('config.inc.php');
//登录检测
if($_SESSION["login"])
{
	
}
else 
{
	if($_REQUEST["yh_mima"]==$cfg['ADMIN_PWD'])
	{
		
		$_SESSION["login"]=$_REQUEST["yh_mima"];
	}
	else 
	{
		
		echo "<script>";
		echo "window.location.href='filelogin.php?error=1'";
		echo "</script>";
	}
}

?>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--link href="http://www.pttmedia.com/ebook_ca_css/css.css" rel="stylesheet" type="text/css" /-->
<head>
</head>
<body>
<?
$view_page_count=15;//每页显示15
if($_REQUEST["page"])
{
	$page=$_REQUEST["page"];
}
else 
{
	$page=0;//
}
if($page<0)
{
	$page=0;
}
$page_row=$page*$view_page_count;

$rows=array();
$toFileFloderandfile = dirname(__FILE__).'/upload/UploadFile.log';

$handle = @fopen($toFileFloderandfile, 'r');
if($handle)
{
	

while (!feof($handle)) {
    $rows[] = fgets($handle, 4096);
   
}
fclose($handle);
$filed_rows=array();
if(count($rows)>0)
{
	$j=0;
	for($i=$page_row;$i<$page_row+$view_page_count;$i++)
	{
		
		$row=$rows[$i];
		
		if(count($row)<0)
		{
			break;
		}
	
		if(strstr($row,'|||'))
		{
			$temp=explode("|||",$row);
			foreach ($temp as $k=>$r)
			{
				$pp="";
				if(strstr($r,'|*|'))//存在多个文件
				{
					$t=explode("|*|",$r);
					if(is_array($t)&&count($t)>0)
					{
						foreach ($t as $v)
						{
							$t1=explode('|&|',$v);
							$_t_file=explode('/',$t1[0]);
							$pp.="<a href='upload/".$t1[0]."'>".$_t_file[1]."</a>&nbsp;&nbsp;大小:".$t1[1]."<br>";
						}
						
					}
					$filed_rows[$j][]=$pp;
				}
				else if(strstr($r,'|&|'))//存在一个文件
				{
					$t=explode("|*|",$r);
					if(is_array($t)&&count($t)>0)
					{
						foreach ($t as $v)
						{
							$t1=explode('|&|',$v);
							$_t_file=explode('/',$t1[0]);
							$pp.="<a href='upload/".$t1[0]."'>".$_t_file[1]."</a>&nbsp;&nbsp;大小:".$t1[1]."<br>";
						}
						
					}
					$filed_rows[$j][]=$pp;
				}
				else{//不是文件 直接输出
					$filed_rows[$j][]=$r;
				}
				
			}
			$j++;
		}
	}
}

$count_rows=count($filed_rows);
?>
<table border="1" cellpadding="1" cellspacing="1" width="90%" align="center" bordercolor="#CCCCCC">
	<tr>
		<th>檔案名稱</th>
		<th>上傳時間</th>
		<?
if(count($string)>0)
{
	foreach ($string as $field)
	{
		?>
		<th><?=$field?></th>
		<?
	}
	?>
		<?
}
?>
	</tr>
	<?
if($count_rows>0)
{
	for ($i=0;$i<$count_rows;$i++)
	{
	?>
	<tr >
		<?
		foreach ($filed_rows[$i] as $row)
		{
			?>
		<td><?=$row?></td>
		<?
		}
	?>
	</tr>
	<?
	}
}
?>
	<tr >
		<td colspan="100" align="right"><?
$zongjilushu=count($rows)-1;
?>
			当前第
			<?=$page+1?>
			页&nbsp;
			共
			<?=ceil($zongjilushu/$view_page_count)?>
			页&nbsp;
			<?=$zongjilushu?>
			条记录&nbsp;
			<?
if($page<=0)
{
	echo "上一页&nbsp;";
}
else 
{
?>
			<a href="filelist.php?page=<?=$page-1?>">上一页</a>&nbsp;
			<?
}
if($zongjilushu<=($page+1)*$view_page_count)
{
	echo "下一页";
}
else 
{
?>
			<a href="filelist.php?page=<?=$page+1?>"">下一页</a>
			<?
}
?>
		</td>
	</tr>
</table>
<?
}
else 
{
	?>
	<div align="center">不存在文件</div>
	<?
}
?>
</body>
</html>
